/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.service;

import br.com.foxline.enums.TypeAnnex;
import br.com.foxline.model.Annex;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author ely
 */
@Stateless
public class AnnexService extends GenericService<Annex> {

    public AnnexService() {
        super(Annex.class);
    }

    public void ajaxTypeAnnex(Annex annex, Annex a) {

        if (annex.getType_annex() == TypeAnnex.ALVARA_CONSTRUCAO) {
            a.setType_annex(TypeAnnex.ALVARA_CONSTRUCAO);
        }
        if (annex.getType_annex() == TypeAnnex.ART) {
            a.setType_annex(TypeAnnex.ART);
        }
        if (annex.getType_annex() == TypeAnnex.CARTA_AFORAMENTO_ORIGINAL) {
            a.setType_annex(TypeAnnex.CARTA_AFORAMENTO_ORIGINAL);
        }
        if (annex.getType_annex() == TypeAnnex.CERTIDAO_REGISTRO_CIVIL) {
            a.setType_annex(TypeAnnex.CERTIDAO_REGISTRO_CIVIL);
        }
        if (annex.getType_annex() == TypeAnnex.CIR) {
            a.setType_annex(TypeAnnex.CIR);
        }
        if (annex.getType_annex() == TypeAnnex.CPF) {
            a.setType_annex(TypeAnnex.CPF);
        }
        if (annex.getType_annex() == TypeAnnex.RG) {
            a.setType_annex(TypeAnnex.RG);
        }
        if (annex.getType_annex() == TypeAnnex.ESCRITURA_PUBLICA) {
            a.setType_annex(TypeAnnex.ESCRITURA_PUBLICA);
        }
        if (annex.getType_annex() == TypeAnnex.HABITE_SE) {
            a.setType_annex(TypeAnnex.HABITE_SE);
        }
        if (annex.getType_annex() == TypeAnnex.ITBI) {
            a.setType_annex(TypeAnnex.ITBI);
        }
        if (annex.getType_annex() == TypeAnnex.PLANTA_ASSINADA) {
            a.setType_annex(TypeAnnex.PLANTA_ASSINADA);
        }
        if (annex.getType_annex() == TypeAnnex.REGISTRO_IMOVEL) {
            a.setType_annex(TypeAnnex.REGISTRO_IMOVEL);
        }
        if (annex.getType_annex() == TypeAnnex.TERMO_INVENTARIO) {
            a.setType_annex(TypeAnnex.TERMO_INVENTARIO);
        }
        if (annex.getType_annex() == TypeAnnex.OUTROS) {
            a.setType_annex(TypeAnnex.OUTROS);
        }
        if (annex.getType_annex() == TypeAnnex.COMPROVANTE_IPTU) {
            a.setType_annex(TypeAnnex.COMPROVANTE_IPTU);
        }
        if (annex.getType_annex() == TypeAnnex.DOCUMENTOS_PESSOAIS) {
            a.setType_annex(TypeAnnex.DOCUMENTOS_PESSOAIS);
        }
        if (annex.getType_annex() == TypeAnnex.AVERBACAO) {
            a.setType_annex(TypeAnnex.AVERBACAO);
        }
        if (annex.getType_annex() == TypeAnnex.PROCURACAO) {
            a.setType_annex(TypeAnnex.PROCURACAO);
        }
    }

    public Annex findUUID(String cod) {
        String sql = "SELECT a FROM Annex a WHERE"
                + " a.cod = :cod ";
        Query query = getEntityManager().createQuery(sql);
        query.setParameter("cod", cod);
        return (Annex) query.getResultList().get(0);
    }
}
